# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-angstrom
_pkgname=angstrom
pkgver=0.15.0
pkgrel=2
pkgdesc="Parser combinators built for speed and memory-efficiency"
url="https://github.com/inhabitedtype/angstrom"
arch="all !riscv64"  # limited by ocaml aport
license="BSD-3-Clause"
depends="ocaml-runtime ocaml-bigstringaf"	# ocaml-lwt
depends_dev="$pkgname=$pkgver-r$pkgrel ocaml-bigstringaf-dev ocaml-lwt-dev"
makedepends="$depends_dev dune ocaml"
checkdepends="ocaml-alcotest-dev ocaml-ppx_let-dev"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/inhabitedtype/angstrom/archive/$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build \
		-p angstrom,angstrom-unix \
		--verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit \
		angstrom angstrom-unix
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
307040a6174f9d3c45a9a3bd3c9d1f4e026aef4a3360bd8d171e2e147306fe0d00ee4cb42019bb2abe8101d25c4a2b5887e466537345eb35246bc34d285ffddf  ocaml-angstrom-0.15.0.tar.gz
"
